package de.LooLo;

import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.widget.ImageView;

/**
 * Spash Screen Activity
 * @author Kevin Seppelt, Lukas Siedel 
 *
 */
public class StartActivity extends Activity {
	
	private ImageView img;
	private AnimationDrawable frameAnimation;
	
	public DatabaseManagement dbs = DatabaseManagement.getInstance();
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.start);
				
		img = (ImageView)findViewById(R.id.animation);
		img.setBackgroundResource(R.anim.start_animation);
		
		final Intent initialIntent;
		
		
		dbs.DataHelper(this);
		if(dbs.selectFirstMenu()){
		initialIntent = new Intent(StartActivity.this,
				MapViewActivity.class);}
		else {initialIntent = new Intent(StartActivity.this,
				LooLoActivity.class);}

		Handler handler = new Handler(); 
	    handler.postDelayed(new Runnable() { 
	         public void run() { 
	        	 startActivity(initialIntent);
	        	 finish();
	         } 
	    }, 3000); 
		
		
	}
	
	public void onResume(){
		super.onResume();
		frameAnimation = (AnimationDrawable) img.getBackground();
	}
	public void onWindowFocusChanged (boolean hasFocus){
		 frameAnimation.start();
	}
}